{extend name="layout" /}
{block name="button"}
    {if authCheck('role/roleadd')}
        <a href="{:url('user/useradd')}"  class="btn btn-mystyle pull-right margin-top">添加管理员</a>
    {/if}
{/block}
{block name="content"}
<div class="table-margin">
    <table class="table table-bordered table-header" id="list-table">
        <thead>
        <tr>
            <td>管理员账号</td>
            <td>绑定角色</td>
            <td>上次登录IP</td>
            <td>上次登录时间</td>
            <td>真实姓名</td>
            <td>状态</td>
            <td class="w15">操作</td>
        </tr>
        </thead>
        <tbody>
        {foreach name="list" item="vo"}
            <tr>
                <td>{$vo['user_name']}</td>
                <td>{$vo['role_name']}</td>
                <td>{$vo['last_login_ip']}</td>
                <td>{$vo['time']}</td>
                <td>{$vo['real_name']}</td>
                <td>{$Think.config.user_status[$vo.status]}</td>
                <td>{$vo['operate']}</td>
            </tr>
        {/foreach}
        </tbody>
        <tfoot>
        <tr>
            <td colspan="7">
                <div class="pull-right">
                    <nav>
                        <ul class="pagination">{$list->render()}</ul>
                    </nav>
                </div>
            </td>
        </tr>
        </tfoot>
    </table>
</div>
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title"> 重置密码</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="{:url('user/reset')}" method="post">
                    <table class="table table-bordered contact-template-form">
                        <tbody><tr>
                            <td width="20%" align="right">原密码：</td>
                            <td>
                                <input class="form-control" type="text" name="old_p" required="" aria-required="true">
                            </td>
                        </tr>
                        <tr>
                            <td width="20%" align="right">新密码：</td>
                            <td>
                                <input class="form-control" type="text" name="new_p" required="" aria-required="true">
                            </td>
                        </tr>
                        <tr>
                            <td width="20%" align="right">确认新密码：</td>
                            <td>
                                <input class="form-control" type="text" name="new_q" required="" aria-required="true">
                            </td>
                        </tr>
                        <tr>
                            <th></th>
                            <td>
                                <input class="btn btn-primary text-white" type="submit" value="提交">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function userDel(id){
        layer.confirm('确认删除此管理员?', {icon: 3, title:'提示'}, function(index){
            //do something
            $.getJSON("{:url('user/userDel')}", {'id' : id}, function(res){
                if(1 == res.code){
                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                        window.location.reload();
                    });
                }else{
                    layer.alert(res.msg, {title: '友情提示', icon: 2});
                }
            });
            layer.close(index);
        })
    }

    // 添加菜单
    function reset(){
        $('#bjy-add').modal('show');
    }
    $(function () {
        $('#bjy-add form').submit(function(){
            $(this).ajaxSubmit({success:showSuccess});
            return false;
        });
    });
    function userDel(){
        layer.confirm('确认删除此管理员?', {icon: 3, title:'提示'}, function(index){
            //do something
            $.getJSON("{:url('user/userDel')}", {'id' : id}, function(res){
                if(1 == res.code){
                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                        window.location.reload();
                    });
                }else{
                    layer.alert(res.msg, {title: '友情提示', icon: 2});
                }
            });
            layer.close(index);
        })
    }
</script>
{/block}
